package com.ssy.lingxi.platform.manage.controller.web;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.api.model.dto.common.CommonIdListDTO;
import com.ssy.lingxi.platform.manage.api.model.vo.shop.ShopVO;
import com.ssy.lingxi.platform.manage.entity.base.Shop;
import com.ssy.lingxi.platform.manage.entity.base.ShopRuleDetail;
import com.ssy.lingxi.platform.manage.model.request.shop.ShopAllAndSuperiorRequest;
import com.ssy.lingxi.platform.manage.model.request.shop.ShopAllReq;
import com.ssy.lingxi.platform.manage.model.response.SelfShopListResp;
import com.ssy.lingxi.platform.manage.service.IShopService;
import com.ssy.lingxi.platform.manage.service.web.IShopWebService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 *@menu web - 商城
 *
 * @author fhj
 * @version 2.0.0
 * @date 2021/09/26
 */
@Api(tags = "web - 商城")
@RestController
@RequestMapping("/manage/web/shopWeb")
public class ShopWebController extends BaseController {

    @Resource
    private IShopWebService shopWebService;
    @Resource
    private IShopService shopService;


    /**
     * 自营商城列表
     * @param shopName 商城名称
     * @return 操作结果
     */
    @GetMapping("/selfShopList")
    public Wrapper<List<SelfShopListResp>> selfShopList(String shopName) {
        return shopWebService.selfShopList(shopName);
    }

    /**
     * 所有
     * @param req 请求参数
     * @return 操作结果
     */
    @PostMapping("/all")
    public Wrapper<List<Shop>> all(@RequestBody @Valid ShopAllReq req) {
        return shopWebService.all(req, getSysUser());
    }

    /**
     * 获取全部商城信息以及当前会员的上级会员的全部商城
     * @param req 请求参数
     * @return 操作结果
     */
    @PostMapping("/allShop")
    public Wrapper<List<Shop>> allShop(@RequestBody @Valid ShopAllAndSuperiorRequest req) {
        return shopWebService.allShop(req, getSysUser());
    }

    /**
     * 获取当前登录会员的web自营商城
     * @param siteId 站点id
     * @return 操作结果
     */
    @GetMapping("/findWebEnterpriseSelfShop")
    public Wrapper<List<Shop>> findWebEnterpriseSelfShop(Long siteId) {
        return shopWebService.findWebEnterpriseSelfShop(siteId,getSysUser());
    }

    /**
     * 获取当前会员的APP自营商城
     * @return 操作结果
     */
    @GetMapping("/findAppSelfShopByCurrMember")
    public Wrapper<List<ShopRuleDetail>> findAppSelfShopByCurrMember() {
        return shopWebService.findAppSelfShopByCurrMember(getSysUser());
    }

    /**
     * 获取当前会员的小程序自营商城
     * @return 操作结果
     */
    @GetMapping("/findAppletsSelfShopByCurrMember")
    public Wrapper<List<ShopRuleDetail>> findAppletsSelfShopByCurrMember() {
        return shopWebService.findAppletsSelfShopByCurrMember(getSysUser());
    }

    /**
     * 根据商城id获取商城信息
     * @param request 请求数据
     * @return 操作结果
     */
    @PostMapping("/byShopIds")
    public Wrapper<List<ShopVO>> byShopIds(@RequestBody @Valid CommonIdListDTO request) {
        return shopService.byShopIds(request);
    }
}
